package com.fr.data.core.define;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.core.ParameterHelper;
import com.fr.report.parameter.Parameter;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class URLDataSource
  implements DataSource
{
  private String url;

  public URLDataSource()
  {
  }

  public URLDataSource(String paramString)
  {
    this.url = paramString;
  }

  public String getUrl()
  {
    return this.url;
  }

  public void setUrl(String paramString)
  {
    this.url = paramString;
  }

  public InputStream getSourceStream(Parameter[] paramArrayOfParameter)
    throws Exception
  {
    String str = ParameterHelper.analyze4Templatee(this.url, paramArrayOfParameter);
    URL localURL = new URL(str);
    URLConnection localURLConnection = localURL.openConnection();
    return localURLConnection.getInputStream();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if ("URL".equals(str2))
      {
        String str1;
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          this.url = str1.trim();
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.url != null)
      paramXMLPrintWriter.startTAG("URL").textNode(this.url).end();
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof URLDataSource) && (ComparatorUtils.equals(this.url, ((URLDataSource)paramObject).url)));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    URLDataSource localURLDataSource = (URLDataSource)super.clone();
    return localURLDataSource;
  }
}